import cv2

# 读取图像
image = cv2.imread('image.jpg', cv2.IMREAD_GRAYSCALE)

# 应用Canny边缘检测
canny_edges = cv2.Canny(image, 100, 200)  # 100和200是阈值

# 显示结果
cv2.imshow('Original Image', image)
cv2.imshow('Canny Edge Detection', canny_edges)
cv2.waitKey(0)
cv2.destroyAllWindows()